<template>
  <div :style="{'direction': $vs.rtl ? 'rtl' : 'ltr'}">
    <feather-icon icon="Edit3Icon" svgClasses="h-5 w-5 mr-4 hover:text-primary cursor-pointer" @click="toEdit(params.data)" />
    <feather-icon icon="Trash2Icon" svgClasses="h-5 w-5 hover:text-danger cursor-pointer" @click="confirmDeleteRecord(params)" />
  </div>
</template>

<script>
export default {
name: 'CellRendererActions',
data(){
  return{
    delete_id:'',
    box_id:''
  }
},
methods: {
  toEdit(row){
    
    // console.log(this.$parent.$parent);
    this.$parent.$parent.editerData = row;
    console.log(this.$parent.$parent);
    this.$parent.$parent.sidebarActive = true;
  },
  editRecord () {
    this.$router.push(`/apps/user/user-edit/${  268}`).catch(() => {})
  },
  confirmDeleteRecord (params) {
    console.log(params);
    this.delete_id = params.data.id;
    this.$vs.dialog({
      type: 'confirm',
      color: 'danger',
      title: '提示',
      text: `确定删除 "${this.params.data.name}"？`,
      accept: this.deleteRecord,
      acceptText: '确定',
      cancelText:'取消'
    })
  },
  deleteRecord () {
    /* Below two lines are just for demo purpose */
    let _this = this;
    _this.$axios({
        url: "/admin/Activity/delcdk",
        method: "post",
        data: {
          id:_this.delete_id
        },
      }).then((res) => {
        //  console.log(res);
        if(res.data.status == 1){
          _this.$parent.$parent.getEenvelopeList();
          _this.showDeleteSuccess()
        }
      });
  

    /* UnComment below lines for enabling true flow if deleting user */
    // this.$store.dispatch("userManagement/removeRecord", this.params.data.id)
    //   .then(()   => { this.showDeleteSuccess() })
    //   .catch(err => { console.error(err)       })
  },
  showDeleteSuccess () {
    this.$vs.notify({
      color: 'success',
      title: '提示',
      text: '删除成功'
    })
  }
}
}
</script>
